package com.bdqn.qnnews.user.controller.v1;

import com.bdqn.qnnews.common.base.R;
import com.bdqn.qnnews.user.service.ApUserService;
import com.bdqn.qnnews.user.vo.LoginReqVo;
import com.bdqn.qnnews.user.vo.UserRespVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xlz
 * @since 2023-12-19
 * @description APP用户信息表
 */
@Slf4j
@RestController
@RequestMapping("/api/v1/login")
@Tag(name = "APP用户登录控制器类",
        description = "app用户登录后端数据接口")
public class ApUserLoginController {
    @Autowired
    private ApUserService apUserService;

    /**
     * 通过id查询 APP用户信息表
     * @param loginReqVo 登录参数
     * @return Result
     */
    @Operation(summary = "登录", description = "基于json格式数据")
    @PostMapping("/login_auth")
    public R<UserRespVo> login(@RequestBody LoginReqVo loginReqVo) {
        log.debug("{}", loginReqVo);
        // 调用服务层登录方法
        final UserRespVo userRespVo = apUserService.login(loginReqVo);

        return R.ok(userRespVo);
    }

}
